package com.dpad.telematicsclientapp.adapter

import android.content.Context
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.widget.ImageView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

import com.dpad.telematicsclientapp.android.R
import com.dpad.telematicsclientapp.mvp.imageloader.ILFactory
import com.dpad.telematicsclientapp.netlibrary.newapp.entity.HomeBean
import com.dpad.telematicsclientapp.util.utils.ImgUtil

/**
 * ================================================
 * 作    者：wenbody
 * 版    本：1.0
 * 创建日期：2019/12/24 17:30
 * 描    述：
 * 修订历史：
 * ================================================
 */
class XzcxShowCarAdapter(context: Context, data: ArrayList<List<HomeBean.CarData>>) : BaseQuickAdapter<List<HomeBean.CarData>, BaseViewHolder>(R.layout.item_child_xzcx, data) {

    private var myContext = context

    override fun convert(helper: BaseViewHolder, item: List<HomeBean.CarData>) {
        val recyclerView = helper.getView<RecyclerView>(R.id.showCarRv)
        recyclerView.layoutManager = LinearLayoutManager(myContext, LinearLayoutManager.HORIZONTAL, false)
        val showCarAdapter = BottomShowCarAdapter(item)
        recyclerView.adapter = showCarAdapter
        showCarAdapter.bindToRecyclerView(recyclerView)
        ILFactory.getLoader().loadNet(helper.getView<ImageView>(R.id.bigCarIm), item[0].imgUrl, ImgUtil.getOptions(R.mipmap.car_default_icon, R.mipmap.xzcx_big1))
        showCarAdapter.setOnItemClickListener { adapter, view, position ->
            for (carItem in item) {
                carItem.check = false
            }
            item[position].check = true

//            helper.setImageResource(R.id.bigCarIm, item[position].bigImageId)
            ILFactory.getLoader().loadNet(helper.getView<ImageView>(R.id.bigCarIm), item[position].imgUrl, ImgUtil.getOptions(R.mipmap.car_default_icon, R.mipmap.xzcx_big1))
            showCarAdapter.notifyDataSetChanged()
        }
    }

}